package com.zhuhjay.service.system.model.dto;

import com.zhuhjay.common.web.annotation.Matching;
import com.zhuhjay.common.web.enums.MatchingMode;
import com.zhuhjay.service.system.model.entity.SystemMenu;
import lombok.Data;

import javax.validation.constraints.Min;

/**
 * @author ZhuHJay
 * @date 2023/6/22 11:19
 */
@Data
public class MenuDto {

    @Matching(MatchingMode.AuthorityName)
    private String menuName;
    @Matching(MatchingMode.AuthorityKey)
    private String menuKey;
    @Min(value = -1, message = "父级菜单id不能小于-1")
    private Integer parentId;
    @Min(value = 1, message = "排序不能小于1")
    private Integer sort;

    public SystemMenu bean2Entity() {
        SystemMenu menu = new SystemMenu();
        menu.setMenuName(menuName);
        menu.setMenuKey(menuKey);
        menu.setParentId(parentId);
        menu.setSort(sort);
        return menu;
    }

}
